package com.hbx.residential_service.service.impl;

import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.CarSiteDao;
import com.hbx.residential_service.domain.CarSite;
import com.hbx.residential_service.service.CarSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CarSiteServiceImpl implements CarSiteService {
    @Autowired
    private CarSiteDao carSiteDao;
    @Override
    public List<CarSite> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page,size);
        return carSiteDao.findAll(page,size);
    }

    @Override
    public void addCarSite(CarSite carSite) {
        carSiteDao.addCarSite(carSite);
    }

    @Override
    public void deleteCarSite(int csId) {
        carSiteDao.deleteCarSite(csId);
    }

    @Override
    public CarSite findUpdCSById(int csId) {
        return carSiteDao.findUpdCSById(csId);
    }

    @Override
    public void UpdateCSById(CarSite carSite) {
        carSiteDao.UpdateCSById(carSite);
    }

    @Override
    public List<CarSite> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return carSiteDao.fsByUsername("%"+content+"%",page,size);
    }
}
